package ru.averta.notes.service.security.login;

import java.util.Collection;
import java.util.Collections;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import ru.averta.notes.domain.User;

public class SecurityUser implements UserDetails {

    private User user;
    private Collection<GrantedAuthority> authorities;

    public SecurityUser(User user, Collection<GrantedAuthority> authorities) {
        this.user = user;
        this.authorities = authorities;
    }

    public User getUser() {
        return user;
    }

    public Collection<GrantedAuthority> getAuthorities() {
        return authorities;
    }

    public String getPassword() {
        return user.getPassword();
    }

    public String getUsername() {
        return user.getMail();
    }

    public boolean isEnabled() {
        //return user.isEnabled(); //TODO
        return true;
    }

    //Нижележащие методы не используем
    public boolean isAccountNonExpired() {
        return true;
    }

    public boolean isAccountNonLocked() {
        return true;
    }

    public boolean isCredentialsNonExpired() {
        return true;
    }
}
